﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DataAccess;
using Model;

namespace Project
{
    /// <summary>
    /// Interaction logic for ViewComplaintPart3.xaml
    /// </summary>
    public partial class PrintComplaintPart3 : UserControl
    {
        private long ComplaintId;
        private List<FunctionaryInfo> EmployeesToAdd;

        public PrintComplaintPart3(long complaintId)
        {
            ComplaintId = complaintId;
            EmployeesToAdd = new List<FunctionaryInfo>();
            InitializeComponent();
            LoadInformation();
        }

        private void LoadInformation()
        {
            var employees = ComplaintDataAccess.GetAllEmployeeOfComplaintFromComp(ComplaintId);
            foreach (var employeeOfComplaint in employees)
            {
                if (employeeOfComplaint.Responsability == "Interviniente")
                {
                    var intervinent = EmployeeDataAccess.GetEmployeeByCi(employeeOfComplaint.CIEmployee);
                    EmployeesToAdd.Add(new FunctionaryInfo
                    {
                        CI = intervinent.CI,
                        Name =
                            intervinent.Name + " " + intervinent.PaternalName + " " +
                            intervinent.MaternalName,
                        Rank = intervinent.Rank,
                        WorkingRole = intervinent.WorkingRole
                    });
                }
                if (employeeOfComplaint.Responsability == "Recepcionista")
                {
                    var recepter = EmployeeDataAccess.GetEmployeeByCi(employeeOfComplaint.CIEmployee);
                    lblRecepterName.Content = recepter.Name + " " + recepter.PaternalName + " " +
                                              recepter.MaternalName;
                    lblRecepterCi.Content = recepter.CI;
                    RecepterInfo.Visibility = Visibility.Visible;
                }
                if (employeeOfComplaint.Responsability == "Asignada")
                {
                    var asignedFuncionary = EmployeeDataAccess.GetEmployeeByCi(employeeOfComplaint.CIEmployee);
                    lblAsignedName.Content = asignedFuncionary.Name + " " + asignedFuncionary.PaternalName + " " +
                                              asignedFuncionary.MaternalName;
                    lblAsignedCi.Content = asignedFuncionary.CI;
                    AsignedInfo.Visibility = Visibility.Visible;
                }
                if (employeeOfComplaint.Responsability == "Jefe de Seguridad")
                {
                    var secBossFuncionary = EmployeeDataAccess.GetEmployeeByCi(employeeOfComplaint.CIEmployee);
                    lblSecBossName.Content = secBossFuncionary.Name + " " + secBossFuncionary.PaternalName + " " +
                                              secBossFuncionary.MaternalName;
                    lblSecBossCi.Content = secBossFuncionary.CI;
                    SecurityBossInfo.Visibility = Visibility.Visible;
                }
            }
            listBoxIntervinents.ItemsSource = EmployeesToAdd;
        }
    }
}
